const login = require('../login/index');
const preview = require('../component/signaturePreview');//签章预览
const affirm = require('../component/receiverAffirm');//确认收件人
const caseDetail = require('../component/caseDetail');//案件详情右侧按钮
const screen = require('../component/screen');//截图
let pupConfig,page, config, filing, caseInfo;

/**
 * 案件受理脚本
 * @param myPupConfig 框架配置信息
 * @param myCaseInfo 案件信息,详见component/caseFile.js
 * @returns {Promise<void>}
 */
const start = async (myPupConfig, myCaseInfo) => {
  pupConfig = myPupConfig;
  page = pupConfig.page;
  config = pupConfig.config.common;
  filing = pupConfig.config.filing;
  caseInfo = myCaseInfo;

  await login(pupConfig, caseInfo.secretaryId);//秘书登录
  await inputRejectInfo();
  await preview(page);
  await affirm(pupConfig, 1);
}

/**
 * 输入案件拒绝受理信息
 */
const inputRejectInfo = async () => {
  //秘书点击拒绝受理按钮
  await caseDetail(pupConfig, caseInfo.caseId, 1);

  await page.waitFor('span textarea');
  await page.type('span textarea', '拒绝受理');

  await screen(page,'拒绝受理案件',1);

  await page.click('.ant-modal-body button');
}

module.exports = start;